package com.centit.suixuan.puremvc.view
{
	import com.centit.suixuan.puremvc.model.User;
	import com.centit.suixuan.puremvc.model.UserProxy;
	
	import flash.events.MouseEvent;
	
	import mx.controls.Alert;
	
	import org.osmf.containers.MediaContainer;
	import org.osmf.layout.LayoutMetadata;
	import org.osmf.layout.LayoutRendererBase;
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	import mx.events.DividerEvent;
	
	import spark.components.Button;
	import spark.components.Panel;
	
	public class MainMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "LoginMediator";
		public static const LOGIN_SUBMIT:String = "LoginSubmit";
		public static const LOGIN_SUCCESSFUL:String = "LoginSuccessful";
		public static const LOGIN_ERROR:String = "LoginError";
		
		
		public function MainMediator(mediatorName:String=null, viewComponent:Object=null)
		{
			super(mediatorName, viewComponent);
			
			(viewComponent as MainApplication).hDividedBox.addEventListener(DividerEvent.DIVIDER_PRESS, dividerPress);
		}
		
		override public function handleNotification(notification:INotification):void
		{
			var loginPanel : MainApplication = notification.getBody() as MainApplication;
			switch(notification.getName()){
				case LOGIN_SUBMIT :     break;
				case LOGIN_SUCCESSFUL : Alert.show("登陆成功");break;
				case LOGIN_ERROR : break;
				default : break;
			}
		}
		
		override public function listNotificationInterests():Array
		{
			return [
				LOGIN_SUBMIT,
				LOGIN_ERROR,
				LOGIN_SUCCESSFUL
			];
		}
		
		
		
		private function dividerPress(e : DividerEvent) : void {
			trace(e.currentTarget);
		}
		
		
	}
}